package com.bjpowernode.boss.common.client;

import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author Mrs.cui
 * 2024-07-08-10-39
 */
@Component
public class RedisClient {
    //string的模板类

    private StringRedisTemplate stringRedisTemplate;

    private  HashOperations<String, Object, Object> hashOps;

    public RedisClient(StringRedisTemplate stringRedisTemplate) {
        this.stringRedisTemplate = stringRedisTemplate;
        hashOps = stringRedisTemplate.opsForHash();
    }

    //定义操作方法
    public Boolean setHashMap(String key, Map<String,String> data, int timeout, TimeUnit timeUnit){
        hashOps.putAll(key, data);
        return stringRedisTemplate.expire(key, timeout,timeUnit);
    }


}
